Skip to content

feat(model): models and web tools can list what they require (#1405 item 2) - #2124

Merged
Mavrick-F merged 3 commits into
opengeos:mainfrom
Mavrick-F:feat/model-requires
Nov 15, 2026
Merged

Mavrick-F merged 3 commits into
opengeos:mainfrom
Mavrick-F:feat/model-requires

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Summary

A model (*.model.json) or web tool (.rgistool) can now list what it needs in requires, as a project can since #1975. model.import refuses one that lists a capability this RustGIS doesn't know, naming it, before it reads the graph or steps:

this model or web tool needs what this RustGIS can't read: futureLoops. Update RustGIS to import it.

That gives saved workflows the way to declare requirements #1405 item 2 asks for. Writers don't change, and nothing lists a capability yet. A later change that an older engine would misread (a new node kind, a new step meaning) adds its name to CAPABILITIES and to the files that use it.

  • The check is feat(project): read project format 2, refusing one that requires a capability this RustGIS doesn't know (#1853 piece 1) #1975's. project::check_requires reads requires from the parsed file with the same bounded reader, so the same refusals apply: at most 256 entries, long names cut, a list that isn't names refused. check_format now uses the same helper, and its messages are unchanged.
  • requires is accepted beside the other top-level fields, so [] or a list of known names imports as before.
  • docs/maintaining.md › Saved files and settings now says models and web tools check requires. Tasks, presentations, notebooks, and models inside a task's steps still don't check it.

This adds an optional field to a saved file whose absence means today's behaviour, so one maintainer can approve it (docs/maintaining.md › Who approves a coordinate-first change).

Testing

  • model_import_refuses_unsupported_files_without_changing_session covers a model and a web tool that require an unknown capability (each name said once) and a requires that isn't a list. Each is refused with the session unchanged.
  • model_import_preserves_supported_and_legacy_files covers both writers' output with "requires": [], which still imports.
  • The project format 2 and requires tests from feat(project): read project format 2, refusing one that requires a capability this RustGIS doesn't know (#1853 piece 1) #1975 still pass after the refactor (format_2…, requires_tests, file_compatibility…, project_save).
  • Fork CI on the head: lint (fmt, clippy -D warnings), workspace tests, layers, wasm build and licences.

UI evidence

No visible change.

Related issue

Closes the remaining part of #1405 item 2.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Model and web-tool files can declare required capabilities, which are checked when those files are opened.
  • Bug Fixes
    • Malformed or unsupported capability declarations are rejected with clearer errors, including when unknown capabilities are repeated.
  • Documentation
    • Saved-file guidance now covers capability declarations for web tools and clarifies that task, presentation, and notebook files—and models embedded in task steps—do not yet validate them.

…s#1405 item 2)

A model or web tool file may carry `requires`, as a project can since opengeos#1975: `model.import`
refuses one that lists a capability this RustGIS doesn't know, naming it, before the graph or
steps are read. A saved workflow can so say what an older engine can't run instead of being
misread. The check is opengeos#1975's, shared through `project::check_requires`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Model and web-tool imports now validate optional requires declarations through shared project capability checks. Workflow tests cover supported declarations, unknown capabilities, duplicate names, and malformed values. The documentation updates which file readers check requires.

Changes: File Capability Imports

Layer / File(s) Summary
Parse and check requirements
crates/engine/src/project.rs
check_requires parses optional JSON requires values. requires_known refuses unknown capabilities and uses the supplied action label in errors.
Validate model and web-tool imports
crates/engine/src/model.rs, crates/engine/tests/workflows.rs, docs/maintaining.md, docs/contributing.md
check_file validates requires declarations and allows the field in model and web-tool files. Workflow tests cover supported and invalid values. The documentation identifies file readers that do not check requires.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Possibly related issues

  • opengeos/RustGIS#1405 — The changes add capability checks for model and web-tool imports, addressing the issue’s request for declared requirements on model files.
  • opengeos/RustGIS#1853 — The changes reuse the shared capability checker for model and web-tool files.

Suggested reviewers: pick2510

Merge Risk: Minimal · up to 2fa04

Model and web-tool imports now refuse files that declare capabilities RustGIS does not support, and they name the unsupported capability. Files without requires, or with known capabilities, keep importing. The change looks safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: models and web tools can declare required capabilities in a requires field, which matches the summaries for model.rs, project.rs, the workflow tests, and the docs. T…
Description check Passed The description follows the template. It has a Summary that explains the change and why, a Testing section that names the tests and CI runs, and a UI evidence section that states 'No visible change.' …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: models and web tools can declare required capabilities in a requires field, which matches the summaries for model.rs, project.rs, the workflow tests, and the docs. The title's scope is accurate and specific. It also cites a tracking item (#1405 item 2), which is acceptable context.

Full details: Description check

Explanation

The description follows the template. It has a Summary that explains the change and why, a Testing section that names the tests and CI runs, and a UI evidence section that states 'No visible change.' The Related issue section names the issue closed. The template's HTML comments are removed, and the sections are filled in. The Related issue section cites #1405 item 2 but does not use the template's 'Closes #' form. That is a minor wording issue, not a gap.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each file with care,
requires lists are parsed there.
Unknown names receive a note,
Empty lists pass without a quote.
Web tools join the models’ queue,
Tests check each case through and through.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 0c699091-8723-4905-a7a5-9a4de6d09d75
Commits

Reviewing files that changed from the base of the PR and between ca0612f and 2fa04d1.

Files selected for processing: 3

  • crates/engine/src/project.rs
  • crates/engine/tests/workflows.rs
  • docs/contributing.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

return Err("this model or web tool has an unsupported version. Update RustGIS to import it.".into());
}
}
crate::project::check_requires(v.get("requires"), "model or web tool", "import")?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latent round-trip gap (confidence: medium, not reachable today). check_file accepts a known capability in requires, but nothing carries that list past import. model.import passes only name and graph/steps to model.new (cmd/sharing.rs:181-185), Model has no field for it, and the writer at model.rs:970 emits only $schema, version, name, graph. So once a capability is added to CAPABILITIES, a file that requires it imports, and the next save or export silently drops the requirement. That is the loss kept_as_written guards against for projects.

It does nothing yet because CAPABILITIES is empty, so any non-empty list is refused. Before the first capability is added, either keep requires on the imported model, or refuse a known capability that the model can't keep. A test with a stub known capability would pin this down.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changed. This matches projects since #1975: a format 2 project that requires only known capabilities opens and saves again as format 1 without requires. CAPABILITIES is the list this RustGIS reads and saves again without loss. So when a capability is added, that same change makes the writer emit it whenever the saved model uses the feature, and a model that doesn't use it needs nothing listed. Keeping an imported list wouldn't help, since it would go stale as soon as the model is edited. The pairing is said where CAPABILITIES is documented (docs/maintaining.md › Saved files and settings: "added to CAPABILITIES where it is read").

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • Latent: a known capability in a model's requires is dropped on save (medium confidence, not reachable today). check_file accepts known names, but model.import passes only name and graph/steps to model.new (cmd/sharing.rs:181-185). The writer at model.rs:970 emits no requires, so once a capability is added to CAPABILITIES, the next save silently loses it. Nothing triggers this yet, because CAPABILITIES is empty and any non-empty list is refused. Posted inline on crates/engine/src/model.rs:842.

Security

  • None found. Requires is reused from the project reader, so the 256-entry and name-length bounds apply, and the new path has no unwrap or indexing.

Performance

  • None found.

Quality

  • Wording mismatch in the refusal (high confidence). unknown_capabilities (project.rs:923, :928) hard-codes "update RustGIS to open it". Only the unknown-names branch uses the open parameter, so a model import refused for requires that isn't a list says "open" rather than "import". The doc comment on check_requires says open drives the refusal, which is not accurate. The kind and open parameters are also always the same two literals.
  • Test does not check dedupe (high confidence). The futureSteps, futureSteps case in workflows.rs:42 uses contains, so a regression that repeats the name would still pass. The PR body claims "each name said once" is covered.

AGENTS.md

  • No violations found. The change adds no project-saved fields, so schema/project.schema.json needs no update, and docs/maintaining.md matches the code. The model and web-tool file has no schema file in the repo.

Confidence: the findings above are medium to high. I did not compile or run the tests; the checks were by reading. Quality items are grouped here, not posted inline, per the review guidance.

Prior reviews: none on this PR, so no earlier concerns were left alone.

Change size

Compared with main (merge base 1ec28d3 to PR head ca0612f).

Measure Value
Files changed 4 (0 added, 4 modified, 0 removed, 0 renamed)
Size before 222.7 KB
Size after 224.9 KB
Total size change +1.9 KB
File Before After Change
crates/engine/src/project.rs 119.7 KB 120.5 KB +840 B
crates/engine/tests/workflows.rs 41.8 KB 42.6 KB +806 B
crates/engine/src/model.rs 54.9 KB 55.1 KB +221 B
docs/maintaining.md 6.3 KB 6.3 KB +53 B

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2124/
Web app https://preview.rustgis.app/pr-2124/app/
Commit 2fa04d1

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

…stGIS to import it

The refusals for a requires list that is too long or not names said "open" for models and web
tools too; they now say what the caller does, as the unknown-name refusal already did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mavrick-F

Copy link
Copy Markdown
Member Author

Review summary: the wording point is fixed in the next push. A model or web tool whose requires is too long or not names now says "update RustGIS to import it". The dedupe case already checks one mention: the expected text can't read: futureSteps. Update doesn't match futureSteps, futureSteps. Update. The round-trip point is answered inline.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs: None found. I checked the check_file ordering, Requires deserialization from a JSON value (crates/engine/src/project.rs:991), the refusal text the new tests match against, and the unchanged check_format messages. Confidence: high.

Security: None found. Input stays bounded through the existing Requires reader, with its 256-entry cap and name truncation. Confidence: high.

Performance: None found. Confidence: high.

Quality:

  • crates/engine/tests/workflows.rs:154: "legacy" => drop(file.as_object_mut().unwrap().remove("version")) works but reads oddly for discarding an Option. A plain statement (file.as_object_mut().unwrap().remove("version");) inside a block would be clearer. Nit, confidence high. Per AGENTS.md this can wait for the release quality pass.

AGENTS.md:

  • docs/contributing.md:96 is now stale. It says "Task, presentation, notebook and model documents don't check requires yet", but this PR makes model files check requires, and only docs/maintaining.md was updated. Suggested wording: "Task, presentation and notebook documents, and models inside a task's steps, don't check requires yet". This file is not in the diff, so I did not post it inline. Confidence high.
  • Checked and fine: no CAPABILITIES or project-save change, so cargo xtask schema isn't needed. schema/fixtures/ only holds .rgis project files, so the fixture rule doesn't apply. Accepting requires: [] drops nothing, and refusals are errors that name the capability.

Prior review threads: One thread (crates/engine/src/model.rs:842, the latent round-trip gap) is already raised. The author replied, and I left it alone. I did not independently verify the author's claim that the model writer emits capabilities from content. With CAPABILITIES empty, nothing is lost today.

Inline comments: None posted. The only in-diff finding is a nit, and the substantive doc issue is outside the diff.

Change size

Compared: the whole PR against main (merge base 1ec28d3 to PR head 9cef117).

Measure Value
Files changed 4 (added 0, modified 4, removed 0, renamed 0)
Size before 222.7 KB
Size after 224.8 KB
Total size change +2.1 KB
Path Before After Change
crates/engine/tests/workflows.rs 41.8 KB 42.7 KB +949 B
crates/engine/src/project.rs 119.7 KB 120.6 KB +917 B
crates/engine/src/model.rs 54.9 KB 55.1 KB +221 B
docs/maintaining.md 6.3 KB 6.3 KB +53 B

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mavrick-F

Copy link
Copy Markdown
Member Author

Follow-up review: docs/contributing.md is fixed in 2fa04d1, with the same wording as docs/maintaining.md. The drop(...) in the test is left for the release quality pass.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the full diff, the staged AGENTS.md, and the surrounding code: project.rs (the Requires reader and check_format), model.rs (check_file), cmd/sharing.rs (model.import), modelbuilder.rs (the UI import path), and the test file. I found no bugs, security problems, or performance problems. No inline comments are warranted, so none are posted.

Bugs: none found. The refactor keeps the existing check_format messages (open), and requires_known rejects both TooMany and NotNames. Every model and web-tool import path goes through model.import → check_file (the UI routes .model.json and .rgistool there), so the check can't be bypassed. Null, [], and a list with a duplicate name behave as the tests expect. Confidence: high.

Security: none found. The new input is bounded by the existing Requires visitor (256 names, long names cut). Confidence: high.

Performance: none found. Confidence: high.

Quality (nits, for the release quality pass):

  • check_requires maps a Requires::deserialize error to "not a RustGIS {kind}: …". That path can't be reached with a serde_json::Value as the code stands, but if it ever were, "not a RustGIS" would be a misleading message for a file that is a RustGIS model. Confidence: medium that it is unreachable; low that it matters.
  • docs/maintaining.md lines 73–74 read "A project, map or layer file, a model or a web tool lists in requires", which is hard to parse as a list. Confidence: high that it's unclear.
  • The PR body says "a list of known names imports as before". With CAPABILITIES empty there are no known names, so that path has no test. This overlaps the open thread on a stub-capability test, so I did not raise it again.

AGENTS.md: no violations found. The change adds no non-test unwrap/expect, and no new error text needs tl!. requires is not part of what a project saves, so cargo xtask schema isn't required. No project read changed, so no schema/fixtures/ entry is required. Confidence: high.

Prior reviews: 1 concern left alone. The thread on the requires round-trip gap (model.import drops a known capability on resave) was answered by the PR author, and neither the code it points at nor its callers changed. The thread is still open, so the maintainers may want to resolve it.

Change size

Compared with the base branch (the whole PR, merge base 1ec28d3 to PR head 2fa04d1).

Measure Value
Files changed 5 (0 added, 5 modified, 0 removed, 0 renamed)
Size before 244.6 KB (250,486 B)
Size after 246.7 KB (252,654 B)
Total size change +2.1 KB (+2,168 B)
Path Before After Change
crates/engine/tests/workflows.rs 41.8 KB 42.7 KB +949 B
crates/engine/src/project.rs 119.7 KB 120.6 KB +917 B
crates/engine/src/model.rs 54.9 KB 55.1 KB +221 B
docs/maintaining.md 6,438 B 6,491 B +53 B
docs/contributing.md 21.9 KB 22.0 KB +28 B

@Mavrick-F

Copy link
Copy Markdown
Member Author

Latest review: the unreachable-message and maintaining.md wording nits are left for the release quality pass.

@Mavrick-F
Mavrick-F merged commit 9b128c4 into opengeos:main Nov 15, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant